﻿using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.ApplicationBlocks.Data;

/// <summary>
/// KindRecord 的摘要说明
/// </summary>
namespace Housing
{
    [Serializable]
    public class KindRecord
    {
        private int _id;
        private string _longid;
        private string _checked;
        private string _location;
        private string _nowarea;
        private string _nowusearea;
        private string _usechange;
        private string _iscontinue;
        private string _starttime;
        private string _stoptime;
        private string _remark;
        private string _date;
        private string _noid;
        private string _reason;


        private int _effectDate;
        public int EffectDate
        {
            get { return _effectDate; }
            set { _effectDate = value; }
        }
        private int _applyid;
        public int Applyid
        {
            get { return _applyid; }
            set { _applyid = value; }
        }

        public KindRecord()
        {}

        public KindRecord(int adjId)
        {
            GetKindRecordById(adjId);
        }

        public int Adj_id
        {
            get { return _id; }
            set { _id = value; }
        }

        public string Adj_longid
        {
            get { return _longid; }
            set { _longid = value; }
        }

        public string Adj_checked
        {
            get { return _checked; }
            set { _checked = value; }
        }

        public string Adj_location
        {
            get { return _location; }
            set { _location = value; }
        }

        public string Adj_nowarea
        {
            get { return _nowarea; }
            set { _nowarea = value; }
        }

        public string Adj_nowuserarea
        {
            get { return _nowusearea; }
            set { _nowusearea = value; }
        }

        public string Adj_usechange
        {
            get { return _usechange; }
            set { _usechange = value; }
        }

        public string Adj_iscontinue
        {
            get { return _iscontinue; }
            set { _iscontinue = value; }
        }

        public string Adj_starttime
        {
            get { return _starttime; }
            set { _starttime = value; }
        }

        public string Adj_stoptime
        {
            get { return _stoptime; }
            set { _stoptime = value; }
        }

        public string Adj_remark
        {
            get { return _remark; }
            set { _remark = value; }
        }

        public string Adj_date
        {
            get { return _date; }
            set { _date = value; }
        }

        public string Adj_noid
        {
            get { return _noid; }
            set { _noid = value; }
        }

        public string Adj_reason
        {
            get { return _reason; }
            set { _reason = value; }
        }
        public static string getmoneychange(string applyid, string effectDate, string nowusearea)
        {
            string moneychange = "";
            SqlParameter[] param = new SqlParameter[4];
            param[0] = new SqlParameter("@applyid", applyid);
            param[1] = new SqlParameter("@EffectDate", effectDate);
            param[2] = new SqlParameter("@nowusearea", nowusearea);
            param[3] = new SqlParameter("@nowuseareaChange", SqlDbType.VarChar, 100);
            param[3].Direction = ParameterDirection.Output;
            SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, "getKindRecordUseChange",param);
            moneychange = param[3].Value.ToString();
            return moneychange;

        }



        protected string connString = SqlHelper.ConnectionString;
        //方法
        public void GetKindRecordById(int adjid)
        {
            string query = "SELECT * FROM KindRecord WHERE adj_id=" + adjid;
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowarea = Utils.GetString(reader[3]);
                Adj_nowuserarea = Utils.GetString(reader[4]);
                Adj_usechange = Utils.GetString(reader[5]);
                Adj_iscontinue = Utils.GetString(reader[6]);
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        public bool AddNewKindRecord(KindRecord kindrecord)
        {
            string query = @"INSERT INTO KindRecord(adj_longid, adj_checked, adj_nowarea, adj_nowusearea,adj_usechange,adj_iscontinue,adj_starttime,adj_stoptime,adj_remark,adj_date,adj_noid,adj_reason,EffectDate,applyid,adj_location) 
                            VALUES('" + kindrecord._longid + "','" + kindrecord._checked + "','" + kindrecord._nowarea + "','" + kindrecord._nowusearea + "',";
            query += "'" + kindrecord._usechange + "','" + kindrecord._iscontinue + "','" + kindrecord._starttime + "','" + kindrecord._stoptime + "','" + kindrecord._remark + "','" + kindrecord._date + "','" + kindrecord._noid + "','" + kindrecord._reason + "'," + kindrecord.EffectDate + "," + kindrecord.Applyid + ",'"+kindrecord.Adj_location+"')";
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, query));
            return result;
        }

        public bool UpdateAKindRecord(KindRecord kindrecord)
        {
            string query = @"UPDATE KindRecord SET adj_longid='" + kindrecord._longid + "', adj_checked='" + kindrecord._checked + "',adj_nowarea='" + kindrecord._nowarea + "', adj_nowusearea='" + kindrecord._nowusearea + "'";
            query += "adj_usechange='" + kindrecord._usechange + "',adj_iscontinue='" + kindrecord._iscontinue + "',adj_starttime='"+kindrecord._starttime+"',adj_stoptime='" + kindrecord._stoptime + "'";
            query += ",adj_remark='" + kindrecord._remark + "',adj_date='" + kindrecord._date + "',adj_noid='" + kindrecord._noid + "',adj_reason='" + kindrecord._reason + "' ,applyid= " + kindrecord.Applyid + "   ,EffectDate= " + kindrecord.EffectDate + "  WHERE adj_id=" + kindrecord._id;
            bool result=Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString,CommandType.Text,query));
            return result;
        }

        public bool DeleteAKindRecord(int adjid)
        {
            string query = "DELETE FROM KindRecord WHERE adj_id="+adjid;
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString,CommandType.Text,query));
            return result;
        }

        public static bool DeleteAKindRecordByApplyid(string applyid)
        {
            string query = "DELETE FROM KindRecord WHERE applyid=" + applyid;
            bool result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, query));
            return result;
        }

        public void GetNewestKindRecordBynoid(string noid)
        {
            string query = "SELECT TOP 1 * FROM KindRecord WHERE adj_noid=" + noid+" AND adj_checked=1 ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowarea = Utils.GetString(reader[3]);
                Adj_nowuserarea = Utils.GetString(reader[4]);
                Adj_usechange = Utils.GetString(reader[5]);
                Adj_iscontinue = Utils.GetString(reader[6]);
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        public void GetNewestKindRecordByApplyid(string applyid)
        {
            string query = "SELECT  * FROM KindRecord WHERE applyid=" + applyid + "  ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowarea = Utils.GetString(reader[3]);
                Adj_nowuserarea = Utils.GetString(reader[4]);
                Adj_usechange = Utils.GetString(reader[5]);
                Adj_iscontinue = Utils.GetString(reader[6]);
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
                Adj_location = Utils.GetString(reader["adj_location"]);
                this.Adj_nowarea = Utils.GetString(reader["adj_nowarea"]);  
            }
            reader.Close();
        }

        public void GetIfContinueThisMonth(string longid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "SELECT TOP 1 * FROM KindRecord WHERE adj_longid='" + longid + "' AND adj_iscontinue=1 AND adj_date=" + time + " ORDER BY adj_id DESC";
            SqlDataReader reader = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (reader.Read())
            {
                Adj_id = (int)reader[0];
                Adj_longid = reader[1].ToString();
                Adj_checked = reader[2].ToString();
                Adj_nowarea = Utils.GetString(reader[3]);
                Adj_nowuserarea = Utils.GetString(reader[4]);
                Adj_usechange = Utils.GetString(reader[5]);
                Adj_iscontinue = Utils.GetString(reader[6]);
                Adj_starttime = Utils.GetString(reader[7]);
                Adj_stoptime = Utils.GetString(reader[8]);
                Adj_remark = Utils.GetString(reader[9]);
                Adj_date = Utils.GetString(reader[10]);
                Adj_noid = Utils.GetString(reader[11]);
                Adj_reason = Utils.GetString(reader[12]);
            }
            reader.Close();
        }

        public void GetIfChangedThisMonth(string longid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "SELECT TOP 1 * FROM KindRecord WHERE adj_longid='" + longid + "' AND adj_iscontinue=0 AND adj_date=" + time + " ORDER BY adj_id DESC";
            SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
            if (dr.Read())
            {
                Adj_id = (int)dr[0];
                Adj_longid = dr[1].ToString();
                Adj_checked = dr[2].ToString();
                Adj_location=dr[3].ToString();
                Adj_nowarea = Utils.GetString(dr[4]);
                Adj_nowuserarea = Utils.GetString(dr[5]);
                Adj_usechange = Utils.GetString(dr[6]);
                Adj_iscontinue = Utils.GetString(dr[7]);
                Adj_starttime = Utils.GetString(dr[8]);
                Adj_stoptime = Utils.GetString(dr[9]);
                Adj_remark = Utils.GetString(dr[10]);
                Adj_date = Utils.GetString(dr[11]);
                Adj_noid = Utils.GetString(dr[12]);
                Adj_reason = Utils.GetString(dr[13]);
            }
            dr.Close();
        }
        
        /// 实物配租调整(增加、减少)(申请)
        public bool ChangeKindOprate(string longid,string noid, string location, string nowarea, string nowusearea, string lastmonthuserarea,
                                    string remark,string oldstoptime,string reason)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt=DateTime.Now.AddMonths(1);
            int starttime = dt.Year * 100 + dt.Month;
            KindRecord kind = new KindRecord();
            kind.GetIfChangedThisMonth(longid);
            if (kind.Adj_iscontinue == "0")
            {
                if (kind.Adj_checked == "1")
                {
                    string olduserarea = kind.Adj_nowuserarea;
                    kind.Adj_checked = "0";
                    kind.Adj_date = time.ToString();
                    kind.Adj_iscontinue = "0";
                    kind.Adj_longid = longid;
                    kind.Adj_noid = noid;
                    kind.Adj_location = location;
                    kind.Adj_nowarea = nowarea;
                    kind.Adj_nowuserarea = nowusearea;
                    kind.Adj_usechange = (float.Parse(nowusearea) - float.Parse(lastmonthuserarea)).ToString();
                    kind.Adj_remark = remark;
                    kind.Adj_starttime = starttime.ToString();
                    kind.Adj_stoptime = oldstoptime;
                    kind.Adj_reason = reason;
                    kind.AddNewKindRecord(kind);
                }
                else
                {
                    kind.Adj_location = location;
                    kind.Adj_nowarea = nowarea;
                    kind.Adj_nowuserarea = nowusearea;
                    kind.Adj_usechange = (float.Parse(nowusearea) - float.Parse(lastmonthuserarea)).ToString();
                    kind.Adj_remark = remark;
                    kind.Adj_date = time.ToString();
                    kind.Adj_reason = reason;
                    kind.UpdateAKindRecord(kind);
                }
            }
            else
            {
                kind.Adj_checked = "0";
                kind.Adj_date = time.ToString();
                kind.Adj_iscontinue = "0";
                kind.Adj_longid = longid;
                kind.Adj_noid = noid;
                kind.Adj_location = location;
                kind.Adj_nowarea = nowarea;
                kind.Adj_nowuserarea = nowusearea;
                kind.Adj_usechange = (float.Parse(nowusearea) - float.Parse(lastmonthuserarea)).ToString();
                kind.Adj_remark = remark;
                kind.Adj_starttime = starttime.ToString(); ;
                kind.Adj_stoptime = oldstoptime;
                kind.Adj_reason = reason;
                kind.AddNewKindRecord(kind);
            }
            return true;
        }

        /// 获取实物配租调整信息
        public DataSet GetKindChanges(string street)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "";
            if (street == "海曙")
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,K.adj_id,A.apply_longid,A.apply_noid FROM Apply AS A INNER JOIN KindRecord AS K ON "
                  + "A.apply_longid=K.adj_longid WHERE K.adj_checked=0 AND K.adj_iscontinue=0 AND K.adj_date=" + time + "  AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid ORDER BY apply_id DESC)";
            else
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,K.adj_id,A.apply_longid,A.apply_noid FROM Apply AS A INNER JOIN KindRecord AS K ON "
                  + "A.apply_longid=K.adj_longid WHERE K.adj_checked=0 AND K.adj_iscontinue=0 AND K.adj_date=" + time + " AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid AND apply_street='" + street + "' ORDER BY apply_id DESC)";
            DataSet ds = SqlHelper.ExecuteDataset(connString, CommandType.Text, query);
            return ds;
        }

        /// 通过---实物配租调整申请
        public bool SetKindChangePass(string longid, int adjid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            KindRecord kind = new KindRecord(adjid);
            //判断本月是否有已审核通过的历史记录
            string query = "SELECT TOP 1 adj_id FROM KindRecord WHERE adj_checked=1 AND adj_longid='" + longid + "' AND adj_date=" + time + " ORDER BY adj_id DESC";
            int ID = SqlHelper.ExecuteNonQuery(connString,CommandType.Text,query);
            if (ID>0)
            {
                //本月有记录则删除原记录，标记新纪录为通过
                SqlConnection conn = new SqlConnection(connString);
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction();
                try
                {
                    query = "DELETE FROM KindRecord WHERE adj_id="+ID;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, query, null);
                    string cmdtext = "UPDATE KindRecord SET adj_checked=1 WHERE adj_id="+adjid;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdtext,null);
                    transaction.Commit();
                    return true;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return false;
                }
            }
            else
            {
                //本月没有记录则标记新纪录为通过
                kind.GetKindRecordById(adjid);
                kind.Adj_checked = "1";
                return kind.UpdateAKindRecord(kind);
            }
        }

        /// 否决---实物配租调整申请
        public bool SetKindChangeUnPass(int adjid)
        {
            KindRecord kind = new KindRecord();
            return kind.DeleteAKindRecord(adjid);
        }

        /// 实物配租续办(申请)
        public bool ContinueKindOprate(string longid,string noid, string stoptime, string remark,string reason)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt = DateTime.Now.AddMonths(1);
            int starttime = dt.Year * 100 + dt.Month;
            KindRecord kind = new KindRecord();
            kind.GetIfContinueThisMonth(longid);
            if (kind.Adj_iscontinue == "1")
            {
                if (kind.Adj_checked == "1")
                {
                    kind.Adj_checked = "0";
                    kind.Adj_date = time.ToString();
                    kind.Adj_iscontinue = "1";
                    //kind.Adj_location = "";
                    //kind.Adj_longid = longid;
                    //kind.Adj_noid = noid;
                    //kind.Adj_nowarea = "";
                    //kind.Adj_nowuserarea = "";
                    kind.Adj_remark = remark;
                    kind.Adj_starttime = starttime.ToString();
                    kind.Adj_stoptime = stoptime;
                    kind.Adj_reason = reason;
                    //kind.Adj_usechange = "";
                    kind.AddNewKindRecord(kind);
                }
                else
                {
                    kind.Adj_remark = remark;
                    kind.Adj_starttime = starttime.ToString();
                    kind.Adj_stoptime = stoptime;
                    kind.Adj_reason = reason;
                    kind.UpdateAKindRecord(kind);
                }
                return true;
            }
            else
            {
                //若本月还没有续办申请，读取该用户最新实物配租信息并添加新纪录
                string query = "SELECT TOP 1 * FROM KindRecord WHERE adj_longid='" + longid + "' AND adj_checked=1";
                SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, query);
                if (dr.Read())
                {
                    kind.Adj_checked = "0";
                    kind.Adj_date = time.ToString();
                    kind.Adj_iscontinue = "1";
                    kind.Adj_location = dr["adj_location"].ToString();
                    kind.Adj_longid = longid;
                    kind.Adj_noid = noid;
                    kind.Adj_nowarea = dr["adj_nowarea"].ToString();
                    kind.Adj_nowuserarea = dr["adj_nowuserarea"].ToString();
                    kind.Adj_remark = remark;
                    kind.Adj_reason = reason;
                    kind.Adj_starttime = starttime.ToString();
                    kind.Adj_stoptime = stoptime;
                    kind.Adj_usechange = dr["adj_usechange"].ToString();
                    dr.Close();
                    return kind.AddNewKindRecord(kind);
                }
                else
                    return false;
            }
        }

        /// 获取实物配租续办信息
        public DataSet GetKindContinues(string street)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            string query = "";
            if (street == "海曙")
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,K.adj_id,A.apply_longid,K.adj_stoptime,K.adj_remark FROM Apply AS A "
                  + "INNER JOIN KindRecord AS K ON A.apply_longid=K.adj_longid WHERE K.adj_checked=0 AND K.adj_iscontinue=1 AND K.adj_date=" + time + " AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid ORDER BY apply_id DESC)";
            else
                query = @"SELECT A.apply_name,A.apply_address,A.apply_time,K.adj_id,A.apply_longid,K.adj_stoptime,K.adj_remark FROM Apply AS A "
                  + "INNER JOIN KindRecord AS K ON A.apply_longid=K.adj_longid WHERE K.adj_checked=0 AND K.adj_iscontinue=1 AND K.adj_date=" + time + " AND A.apply_id "
                  + "IN (SELECT TOP 1 apply_id FROM Apply WHERE apply_updchecked=1 AND apply_longid=A.apply_longid AND apply_street='" + street + "' ORDER BY apply_id DESC)";
            DataSet ds = SqlHelper.ExecuteDataset(connString, CommandType.Text, query);
            return ds;
        }

        /// 通过---实物配租续办申请
        public bool SetKindContinuePass(string longid,int adjid)
        {
            int time = DateTime.Now.Year * 100 + DateTime.Now.Month;
            DateTime dt=DateTime.Now.AddMonths(1);
            int nextmonth = dt.Year * 100 + dt.Month;
            KindRecord kind = new KindRecord(adjid);
            //判断本月是否有已审核通过的历史记录
            string query = "SELECT TOP 1 adj_id FROM KindRecord WHERE adj_checked=1 AND adj_longid='" + longid + "' AND adj_date=" + time + " ORDER BY adj_id DESC";
            int ID = SqlHelper.ExecuteNonQuery(connString,CommandType.Text,query);
            if (ID>0)
            {
                //本月有记录则删除旧记录，更新新纪录
                SqlConnection conn = new SqlConnection(connString);
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction();
                try
                {
                    query = "DELETE FROM KindRecord WHERE adj_id=" + ID;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, query, null);
                    string cmdtext = "UPDATE KindRecord SET adj_checked=1 WHERE adj_id=" + adjid;
                    SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdtext, null);
                    transaction.Commit();
                    return true;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return false;
                }
            }
            else
            {
                //本月没有记录则标记新纪录为通过
                kind.GetKindRecordById(adjid);
                kind.Adj_checked = "1";
                return kind.UpdateAKindRecord(kind);
            }
        }

        /// 否决----实物配租续办申请
        public bool SetKindContinueUnPass(int adjid)
        {
            KindRecord kind = new KindRecord();
            return kind.DeleteAKindRecord(adjid);
        }

        public bool SetContinuePass(string noid, string adjid, string tablename, string columname, string timename, string time)
        {
            DateTime dt = DateTime.Now.AddMonths(1);
            string cmdtext = "UPDATE Indemnity SET " + timename + "='" + time + "' WHERE ind_id IN(SELECT MAX(ind_id) FROM Indemnity WHERE ind_noid=" + noid + " AND ind_updchecked=1)";
            bool succ = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, cmdtext));
            if (succ)
            {
                string cmdtext2 = "SELECT top 1 * FROM " + tablename + " WHERE adj_iscontinue=1 AND ind_noid=" + noid + " AND " + timename + "='" + dt.Year.ToString() + "-" + dt.Month.ToString() + "-1 00:00:00" + "' AND adj_id!=" + adjid + " ORDER BY adj_id DESC";
                SqlDataReader dr = SqlHelper.ExecuteReader(connString, CommandType.Text, cmdtext2);
                if (dr.Read())
                {
                    string cmdtext1 = "DELETE FROM " + tablename + " WHERE adj_id=" + adjid;
                    SqlHelper.ExecuteNonQuery(connString, CommandType.Text, cmdtext1);
                    string cmdtext3 = "UPDATE " + tablename + " SET " + timename + "='" + time + "' WHERE adj_id=" + dr["adj_id"].ToString();
                    bool succupd = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, cmdtext3));
                    return succupd;
                }
                else
                {
                    string cmdtext1 = "UPDATE " + tablename + " SET " + columname + "=1 WHERE adj_id=" + adjid;
                    bool succupd = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, cmdtext1));
                    return succupd;
                }
            }
            else
                return false;
        }

        public bool SetContinueUnpass(string id, string tablename)
        {
            string cmdtext = "DELETE FROM " + tablename + " WHERE adj_id = " + id;
            bool succ = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(connString, CommandType.Text, cmdtext));
            return succ;
        }
    }
}